package com.hzhr.iot.cqgas.ds.service;

import com.hzhr.iot.cqgas.ds.dao.toll.example.TollOptionsDao;
import com.hzhr.iot.cqgas.ds.entity.toll.TollOptionsEntity;
import com.hzhr.iot.cqgas.ds.entity.toll.TollOptionsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TollOptionsService {
    @Autowired
    TollOptionsDao tollOptionsDao;

    public String getCode(String typeName, String name) {
        TollOptionsExample tollOptionsExample = new TollOptionsExample();
        tollOptionsExample.createCriteria()
                .andTypeNameEqualTo(typeName)
                .andNameEqualTo(name);
        List<TollOptionsEntity> tollOptionsEntities = tollOptionsDao.selectByExample(tollOptionsExample);
        if (tollOptionsEntities.size() == 0) return null;
        return tollOptionsEntities.get(0).getCode();
    }
}
